/*
 * Thanks to: http://www.twmacinta.com/myjava/fast_md5.php
 */
package com.meevle.utilities;

import java.io.UnsupportedEncodingException;

import org.red5.core.ApplicationSettings;

import com.twmacinta.util.MD5;

public class MD5HashCalculator {

private volatile static MD5HashCalculator instance = null;
	
	private MD5HashCalculator()
	{}
	
	public static MD5HashCalculator getInstance () {
        if (instance == null)
        {
        	synchronized (MD5HashCalculator.class)
        	{
        		if (instance == null) instance = new MD5HashCalculator();
			}
        }
        return instance;
    }
	
	public String getHash(String toBeConverted)
	{
		String hash = null;
	    try {
	    	MD5 md5 = new MD5();
			md5.Update(toBeConverted, null);
			hash = md5.asHex();
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
	    return hash;
	}
}
